/*
 * Copyright 2009 rashaguo <rashaguo@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef SERVICEXML_H
#define SERVICEXML_H

#include <string>

/**
 * This class to parse the myservice.xml, prepare the xml to send to friends.
 * Feature:
 * - Parse the myservice.xml provided by user to get the enabled service.
 * - Return the xml for sending
 *   -- Add web server IP port infomation
 *   -- Remove the disable service
 */

class QFile;

class ServiceXml
{
public:

    ServiceXml(std::string xml);

    ServiceXml(QFile &file);

    ~ServiceXml();

    bool validXml();

    // add web server info -- specified
    // remove the disabled service
    std::string preSendProcess();

    std::string postReceivedProcess();

    std::string getContentType() const {
        return m_type;
    }

    unsigned long long getLength() const {
        return m_length;
    }

private:

    void purgeXml();

    void addWebServerInfo();

    void xml2html();

    std::string m_xml;

    std::string m_type;

    unsigned long long m_length;
};

#endif
